<?php

namespace app\common\model\Hotel;

// 引入TP基础模型
use think\Model;

//  酒店房间模型 
class  Room extends Model
{
    protected $name = 'hotel_room';

    protected $append = [
        'thumb_text', // 酒店图片
        'flag_text', // 服务标签
    ];

    public function getThumbTextAttr($value, $data)
    {
        $url = request()->domain();

        $thumb = !empty($data['thumb']) ? $data['thumb'] : '/assets/img/hotel.jpg';

        return $url . $thumb;
    }
    
    public function getFlagTextAttr($value, $data)
    {
        $flag = isset($data['flag']) ? trim($data['flag']) : '';

        $list = explode(',', $flag);

        return $list;
    }
}
